<!-- 设备台账 物业-公区 -->
<template>
	<div class="zs-table-page-container">
		<div class="zs-card-sm zs-space-bottom zs-layout-flex-row zs-layout-justify-between">
			<div>
				<el-input v-model="projectName" class="zs-select-md" disabled />
			</div>
		</div>

		<!-- teble -->
		<div class="zs-card zs-table-page-content">
			<el-table class="zs-table-page-main" :data="tableData.data" v-loading="tableData.loading" stripe>
				<el-table-column type="index" label="序号" width="60" :align="'center'" :index="index => index + 1 + (tableData.currentPage - 1) * curPageSize" />
				<el-table-column prop="no" label="表号" show-overflow-tooltip align="left" :formatter="defaultTableData" />
				<el-table-column prop="proId" label="项目id" show-overflow-tooltip align="left" :formatter="defaultTableData" />
				<el-table-column prop="proName" label="项目名称" show-overflow-tooltip align="left" :formatter="defaultTableData" />
				<el-table-column prop="name" label="商户名" show-overflow-tooltip align="left" :formatter="defaultTableData" />
				<el-table-column prop="bei" label="倍率" show-overflow-tooltip align="right" :formatter="defaultTableData" />
				<el-table-column prop="bjlxName" label="类型" show-overflow-tooltip align="center" :formatter="defaultTableData" />
			</el-table>
			<div class="zs-space-top-sm zs-table-page-pagination">
				<el-pagination v-model:currentPage="tableData.currentPage" v-model:page-size="curPageSize" :page-sizes="curPageSizes" :small="true" :background="true" layout="total, sizes, prev, pager, next, jumper" :total="tableData.total" @size-change="pageChange('size', $event)" @current-change="pageChange('page', $event)" />
			</div>
		</div>
	</div>
</template>

<script setup>
	import { defaultTableData } from '@/utils/publicUtils';
	import Energy from '@/api/Energy';
	import { ref, reactive } from 'vue';
	import { useStore } from 'vuex';
	import { useRoute } from 'vue-router';

	const routeQuery = useRoute().query;
	let store = useStore();
	const curPageSizes = ref(store.state.uiPageSizes);
	const curPageSize = ref(store.state.uiPageSizeDefault);
	const projectName = decodeURI(routeQuery.projectName || '');

	// 列表 filed
	let tableData = reactive({
		currentPage: 1,
		total: 0,
		loading: false,
		data: [],
	});

	//查询条件
	let searchObj = reactive({ pageNumber: 1, pageSize: curPageSize.value, energyMeterConfigId: routeQuery.id });

	// //列表数据源
	const queryList = async () => {
		tableData.loading = true;
		let res = await Energy.facilityStandingPropertyAreaListApi(searchObj);
		if (res.data.code !== 200) return;
		tableData.data = res.data.data.list;
		tableData.total = res.data.data.total || 0;
		tableData.loading = false;
	};

	// 分页
	const pageChange = (type, size) => {
		if (type == 'size') {
			searchObj.pageSize = size;
		} else {
			searchObj.pageNumber = size;
		}
		queryList();
	};

	queryList();
</script>
